package com.welab.task3.config;

import javax.servlet.http.HttpSession;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author dammein.yuan
 * @version v1.0
 * @Title: com.welab.task3.config
 * @Description: swagger配置
 * @Copyright: © 2020 ***
 * @Company: ***有限公司
 * @date 2020-3-9
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig implements WebMvcConfigurer {

  @Bean
  public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
        .useDefaultResponseMessages(false)
        .ignoredParameterTypes(HttpSession.class)
        .apiInfo(apiInfo())
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.welab.task3.controller"))
        .paths(PathSelectors.any())
        .build();
  }

  private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
        .title("用户管理系统")
        .description("用户管理系统后台接口")
        .version("1.0")
        .build();
  }
//    @Override
//    public void  addResourceHandlers(ResourceHandlerRegistry registry){
//        registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/schoolSpace/upload/");
//
//    }
}
